/**
 * Created by webhugo on 16-10-16.
 */
var sequelizex = require('sequelize-short');
var shortDataTypes = sequelizex.DataTypes;
module.exports = function (sequelize, DataTypes) {

    var Chapter = sequelize.define('Chapter', {
        title: shortDataTypes.String(),
        num: shortDataTypes.Int()
    }, {
        associate: function (models) {
            models.Course.hasMany(models.Chapter);
            models.Chapter.belongsTo(models.Course);

            models.Chapter.hasMany(models.Lesson);
            models.Lesson.belongsTo(models.Chapter);
        },
        instanceMethods: {
        }
    });

    return Chapter;
};
